package com.fs.modules.ad;

import com.fs.AdFeignService;
import com.fs.test.entity.AdEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;


@Controller
@RequestMapping("/ad/ad")
public class AdController {

    @Autowired
    AdFeignService adFeignService;

    @ResponseBody
    @GetMapping(value = "/list")
//    @HystrixCommand(fallbackMethod = "processHystrix_Get")
    public List<AdEntity> loadDataList() {

        List<AdEntity> list = adFeignService.getAdList();
        return list;
    }
//
//    @ResponseBody
//    @RequestMapping(value = "/testList")
//    public Object loadTestList() {
//        List<String> list = adFeignService.getTestList();
//        //List<AdEntity> list = new ArrayList<>();
//        return list;
//    }

    public List<AdEntity> processHystrix_Get() {
        List<AdEntity> list = new ArrayList<>();
        AdEntity adEntity = new AdEntity();
        adEntity.setAdId(2);
        adEntity.setTitle("该ID：\" + id + \"没有没有对应的信息,null--@HystrixCommand");
        list.add(adEntity);
        return list;
    }

    public void testArrayList() {
        List<String> list = new ArrayList<>();
        list.add("nihoa");
        List<String> list1 = new ArrayList<>(list);
        System.out.println();
    }

}
